@extends('layout.master')

@section('title','健康档案')

@section('css')
    @parent
    <style>
        .form-material .form-group.stySelect {
            overflow: visible;
        }

        .form-material button.form-control {
            padding: .8rem 25px .8rem 1.2rem;
            border: 1px solid #e4e7ea;
        }

        .dropify-wrapper {
            border: 0;
        }

    </style>
@endsection
@section('main')
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <div class="row">
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">创建人</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ \App\User::where('uuid', $healthRecords->user_uuid)->value('name') }}"
                                       name="user_uuid"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">病人姓名</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->name }}"
                                       name="name"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-1">
                        <div class="form-group">
                            <label class="col-md-12">病人性别</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $healthRecords->sex }}"
                                       name="sex"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-1">
                        <div class="form-group">
                            <label class="col-md-12">病人年龄</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $healthRecords->age }}"
                                       name="age"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">病人与创建人关系</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->relationship }}"
                                       name="relationship"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">病人生日</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->birthday }}"
                                       name="birthday"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">病人联系方式</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->telephone }}"
                                       name="telephone"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label class="col-md-12">疾病史</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->history_disease_name }}"
                                       name="history_disease_name"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-8">
                        <div class="form-group">
                            <label class="col-md-12">地址</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->address . $healthRecords->address_detail }}"
                                       name="history_disease_name"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <label class="col-md-12"><p style="color: red;">*以下为选填</p></label>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">过敏史</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->allergy }}"
                                       name="allergy"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">常去医院</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->hospital }}"
                                       name="hospital"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">常去诊所</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->clinic }}"
                                       name="clinic"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">常去药店</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->pharmacy }}"
                                       name="pharmacy"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">慢性病</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->diseases }}"
                                       name="diseases"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">常用药</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ $healthRecords->medicines }}"
                                       name="medicines"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        @if($healthRecords->status == \App\HealthRecords::STATUS_WAITING)
                            <label class="col-md-12">信息审核</label>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="status-on">审核通过
                            </button>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="status-off">审核不通过
                            </button>
                        @endif
                        <a class="fcbtn btn btn-success btn-outline btn-1e waves-effect"
                           href="{{ url('/healthRecords/list') }}">返回
                        </a>
                    </div>

                </div>
            </div>


            @if($healthRecords->status == \App\HealthRecords::STATUS_NEW)
                <div class="white-box">
                    <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">病人姓名</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->name }}"
                                           name="name"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-1">
                            <div class="form-group">
                                <label class="col-md-12">病人性别</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $new->sex }}"
                                           name="sex"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1">
                            <div class="form-group">
                                <label class="col-md-12">病人年龄</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $new->age }}"
                                           name="age"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">病人与创建人关系</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->relationship }}"
                                           name="relationship"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">病人生日</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->birthday }}"
                                           name="birthday"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">病人联系方式</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->telephone }}"
                                           name="telephone"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="col-md-12">疾病史</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->history_disease_name }}"
                                           name="history_disease_name"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-8">
                            <div class="form-group">
                                <label class="col-md-12">地址</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->address . $new->address_detail }}"
                                           name="history_disease_name"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-md-12"><p style="color: red;">*以下为选填</p></label>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">过敏史</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->allergy }}"
                                           name="allergy"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">常去医院</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->hospital }}"
                                           name="hospital"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">常去诊所</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->clinic }}"
                                           name="clinic"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">常去药店</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->pharmacy }}"
                                           name="pharmacy"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">慢性病</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->diseases }}"
                                           name="diseases"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="col-md-12">常用药</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ $new->medicines }}"
                                           name="medicines"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <label class="col-md-12">信息审核</label>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="new-on">审核通过
                            </button>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="new-off">审核不通过
                            </button>
                        </div>

                    </div>
                </div>
            @endif
        </div>
    </div>

@endsection
@section('js')
    @parent
    <script src="{{ asset('js/myself.js') }}"></script>
    <script type="text/javascript">

        $('#status-on').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/healthRecords/statusOn/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
        $('#status-off').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定不通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/healthRecords/statusOff/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });


        $('#new-on').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/healthRecords/newStatusOn/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
        $('#new-off').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定不通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/healthRecords/newStatusOff/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
    </script>
@endsection